

function randomMime(nMime,nRows,nCols) {
    let mimes = [];
    let existed = {};
    for (let i = 0; i < nMime; i++) {
        while (true) {
            let rowIdx = Math.floor(Math.random()*nRows);
            let colIdx = Math.floor(Math.random()*nCols);
            let key = "${rowIdx},${colIdx}";
            if (key in existed) {
                continue;
            }

            mimes.push([rowIdx,colIdx]);
            existed[key] = true;
            break;
        }
    }

    return mimes;
}

function drawMimeGrid(nRows, nCols) {
    let tblEl = document.querySelector("#gameboard > table.mime-grid");
    console.log(tblEl);

    for (let rowIdx = 0; rowIdx < nRows; rowIdx++) {
        let trEl = document.createElement("tr");
        for (let colIdx = 0; colIdx < nCols; colIdx++) {
            let tdEl = document.createElement("td");

            let cellDiv = document.createElement("div");
            cellDiv.className = "cell";
            tdEl.append(cellDiv);
            trEl.append(tdEl);
        }

        tblEl.append(trEl);
    }

}

function main() {
    console.log("main")

    let mimes = randomMime(10,9,9);
    console.log(mimes);

    drawMimeGrid(9, 9);
    
}